<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="pragma" content="no-cache"/>   
<meta http-equiv="Cache-Control" content="no-cache, must-revalidate"/>   
<meta http-equiv="expires" content="0"/>  
<title>ftp通用上传页</title>
<link href="css/style.css" rel="stylesheet" type="text/css" />
<link href="css/out.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/jquery.idTabs.min.js"></script>
<script type="text/javascript" src="editor/kindeditor.js"></script>
<script type="text/javascript" src="js/jquery.form.js"></script>
<script type="text/javascript" src="laydate/laydate.js"></script>
</head>
<body>
	<div class="incList" name="dataList">
	    <div class="place" >
	        <span>位置：</span>
	        <ul class="placeul">
	            <li><a href="#">智能硬件</a></li>
	            <li><a href="#">电子屏</a></li>
	            <li><a href="#">上传ftp</a></li>
	        </ul>
	    </div>
	    <div class="formbody">
			<form id="ftpUpload" method="post" enctype="multipart/form-data">
				<div class="tools">
					<ul class="seachform">
						<li>
							<label>选择设备</label>
							<div class="vocation">
								<select class="tlselect" name="path" id="path">
									<option value="0" selected>请选择</option>
								</select>
							</div>
						</li>
					</ul>
				</div>

				<input type="file" name="file1" id="file1">

				<input name="btnSave"  id="btnSave"  type="button" class="btn" value="上传"/>
			</form>
		</div>
	</div>
<script type="text/javascript">
	$(function(){
        $.post('/euc/commUpload/uploadSelect',function(result){
            var data = result.data;
            $("#path").html("<option value='0' selected>请选择</option>");
            for(var i = 0,leng = data.length;i<leng;i++){
                $("#path").append("<option value='"+data[i].value+"'>"+data[i].label+"</option>");
            }
        });

        $("#btnSave").click(function(){
            var sel = $("#path").val();
            if(sel == 0 || sel == null){
                alert("请选择上传设备");
                return ;
			}
            uploadFiles();
		});
	});

	function uploadFiles() {
        var form = new FormData(document.getElementById("ftpUpload"));
        $.ajax({
            url: "/euc/commUpload/ftpUpload",
            type: "POST",
            processData:false,
            contentType:false,
            data: form,
            success: function (data) {

                var file = document.getElementById('file1');
                file.value = '';
				alert(data.message);
            },
            error: function (data) {
				alert("上传失败");
            }
        });
    }
</script>
</body>
</html>
